<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>

<!--使用JSP page指令引入类， *为通配符，表示包下面所有的类  -->
<%@page import="com.sample.jdbc.JdbcUtils"%>
<%@page import="java.sql.*"%>
<%

String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>My JSP 'user_del_Action.jsp' starting page</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
<%
//使用request对象的getParameter()接收请求参数的值  
    String uid=request.getParameter("id");
   
    JdbcUtils jdbcUtils= new JdbcUtils();

//使用JdbcUtils组件的getConn()方法连接数据库，由连接对象创建发送SQL命令给数据库的Statement类型的对象，构造删除SQL语句，Statement类型的对象执行executeUpdate()方法 完成删除某一条记录。    
    try{
    
    Connection conn =jdbcUtils.getConn();
    
    Statement stmt =conn.createStatement();
    
    String sql="delete from t_user where id = '"+uid+"'";
    
    stmt.executeUpdate(sql);
    
    //重定向到指定URL
    response.sendRedirect(path+"/page/user_list.jsp");
    
    }catch(Exception e){
    
    e.printStackTrace();
    }
  
   %>

<body>
	删除成功！
	<br>
</body>
</html>



